package com.wuye.action;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wuye.dao.UsersDaoImpl;
import com.wuye.entity.Jiaofei;
import com.wuye.entity.Weixiu;
import com.wuye.service.JiaofeiService;

@Controller
@RequestMapping("/jiaofei")
public class JiaofeiAction {
	@Resource
	private JiaofeiService jiaofeiService;
	@Resource
	private UsersDaoImpl userDao;
	
	//跳转页面
		@RequestMapping("/goPage")
		public String goPage(HttpServletRequest request){
			request.setAttribute("list", userDao.getComboxList());
			jiaofeiService.goPage(request);
			return "../jf.jsp";
		}
	//增加
	@RequestMapping("/save")
	public String save(Jiaofei jiaofei,HttpServletRequest request){
		jiaofeiService.save(jiaofei);
		request.setAttribute("msg", "已缴费");
		return "goPage.do";
	}
	//删除
	@RequestMapping("/del")
	public String del(String str,HttpServletRequest request){
		jiaofeiService.del(str);
		request.setAttribute("msg", "已删除");
		return "goPage.do";
	}
	//更新
	@RequestMapping("/update")
		public String update(String str,HttpServletRequest request){
		jiaofeiService.update(str);
			request.setAttribute("msg", "已处理");
			return "goPage.do";
		}
	//列表
	@RequestMapping("/allList")
	public @ResponseBody Map getAllList(String page,String rows,HttpServletRequest request){
		int intPage = Integer.parseInt((page == null || page =="0") ? "1":page); 
        int number = Integer.parseInt((rows == null || rows =="0") ? "10":rows); 
        int start = (intPage-1)*number; 
        return jiaofeiService.getList(start,number);
	}
	//查询
	@RequestMapping("/searchList")
	public @ResponseBody Map getSearchList(Jiaofei jiaofei,String page,String rows,String shijian1,String shijian2,HttpServletRequest request) throws Exception{
		int intPage = Integer.parseInt((page == null || page =="0") ? "1":page); 
        int number = Integer.parseInt((rows == null || rows =="0") ? "10":rows); 
        int start = (intPage-1)*number; 
        return jiaofeiService.getSearchList(jiaofei,start,number,shijian1,shijian2);
	}
	public JiaofeiService getJiaofeiService() {
		return jiaofeiService;
	}
	public void setJiaofeiService(JiaofeiService jiaofeiService) {
		this.jiaofeiService = jiaofeiService;
	}
	public UsersDaoImpl getUserDao() {
		return userDao;
	}
	public void setUserDao(UsersDaoImpl userDao) {
		this.userDao = userDao;
	}
}
